--~ DEBUG = true
require"json"
require"dump"

local sqlite = require"lsqlite3"
db = sqlite.open("wowhead.db")
db:exec("SELECT content, url FROM cache WHERE url LIKE '%npc=%' LIMIT 1",
	function (_, _, values, _)
		local content = values[1]
		local result = {}
		for view in content:gmatch("new Listview(%b())") do
			local name = view:match("id: '([^']+)'")
			local list = view:match("data%: (%b[])")
			if list then
				result[name] = json.decode(list)
			end
		end
		dump(values[2], result)
		return 0
	end)
